package com.ticorp.framework.web.bean;

import java.util.Map;

import org.apache.commons.lang.StringUtils;

public class BapiReturnBean {
	public static final String RETURN = "RETURN";

	public static final String SUCCESS = "S";

	public static final String ERROR = "E";
	
	public static final String INFORMATION = "I";

	private String type;

	private String code;

	private String message;

	public BapiReturnBean(Map map) {
		if (map.get(RETURN) instanceof Map) {
			map = (Map) map.get(RETURN);
		}
		this.type = (String) map.get("TYPE");
		this.code = (String) map.get("CODE");
		this.message = (String) map.get("MESSAGE");
	}
	
	public BapiReturnBean(String type, String message){
		this.type = type;
		this.message = message;
	}

	public boolean isSuccess() {
		return StringUtils.equals(type, SUCCESS);
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
}
